<?php 
    $content=LoadConfig::$content;
    $type_content=LoadConfig::$type_content;
    $url= new Url();
    $current_url = Common::getCurrentUrl();
    $path_paging = strpos($current_url,'?') !==false ? $current_url.'&' : $current_url.'?';
    $path_paging = str_replace("?page=".$page."&","?",$path_paging);
    $path_paging = str_replace("&page=".$page."&","&",$path_paging);
?>
<div class="main clearfix">
    <div class="Tabs clearfix">
        <ul class="clearfix">
            <li><a href="<?php echo Url::createUrl("customerCare/index"); ?>" ><span>Báo lỗi</span></a></li>
            <li><a href="<?php echo Url::createUrl("customerCare/logsms"); ?>" class="active" ><span>Log Sms</span></a></li>
            <li><a href="<?php echo Url::createUrl("customerCare/logcard"); ?>"><span>Log Card</span></a></li>
        </ul>                
    </div>
    <div class="box clearfix bottom30">
        <form action="" method="get" name="form1">
            <ul class="form4">
                <li class="clearfix"><label><strong>Từ ngày </strong>:</label>
                    <div class="filltext">
                        <?php
                            $this->widget(
                            "zii.widgets.jui.CJuiDatePicker"
                            , array(
                            "name"=>"from_date"
                            , "id"=>"from_date"
                            , "value"=>$from_date                                                                
                            , "options"=> array(
                            'showAnim' => 'fold'
                            , 'dateFormat' => 'dd-mm-yy'
                            , 'changeYear' => 'true'
                            , 'changeMonth' => 'true'
                            , 'showOn' => 'both'
                            , 'buttonText' => '<input type="button" name="" value="" class="ic-date">'
                            )
                            , 'htmlOptions' => array(
                            'style' => 'width:170px'
                            , 'class' => 'form'
                            )
                            )
                            );
                        ?>                                       
                        &nbsp;đến ngày &nbsp; 
                        <?php
                            $this->widget(
                            "zii.widgets.jui.CJuiDatePicker"
                            , array(
                            "name"=>"to_date"
                            , "id"=>"to_date"
                            , "value"=>$to_date
                            , "options"=> array(
                            'showAnim' => 'fold'
                            , 'dateFormat' => 'dd-mm-yy'
                            , 'changeYear' => 'true'
                            , 'changeMonth' => 'true'
                            , 'showOn' => 'both'
                            , 'buttonText' => '<input type="button" name="" value="" class="ic-date">'
                            )
                            , 'htmlOptions' => array(
                            'style' => 'width:170px'
                            , 'class' => 'form'
                            )
                            )
                            );
                        ?>
                    </div>
                </li>
                
                <li class="clearfix"><label><strong>Từ khóa </strong>:</label>
                    <div class="filltext">
                        <input name="name_search" type="text" value="<?php  if(isset($name_search)){echo $name_search; } ?>" style="width:197px;margin-right:28px"> Theo &nbsp
                        <select onclick="toggleApp()" name="search_type" style="width:140px; height: 23px;">
                            <option value="2" <?php if(isset($search_type) && $search_type==3){ echo "selected=selected";} ?>> -- Tên tài khoản --</option>
                            <option value="3" <?php if(isset($search_type) && $search_type==3){ echo "selected=selected";} ?>> -- Đầu số --</option>
                            <option value="4" <?php if(isset($search_type) && $search_type==4){ echo "selected=selected";} ?>> -- Số điện thoại --</option>
                            <option value="5" <?php if(isset($search_type) && $search_type==5){ echo "selected=selected";} ?>> -- Sản phẩm --</option>
                        </select>

                        <select id="content_type" name="content_type" style="width:120px; height: 23px;display: none;">
                        <?php foreach($content as $key=>$value){ ?>
                            <option value="<?php echo $key; ?> " <?php if(isset($content_type) && $content_type==$key){ echo "selected=selected";} ?>> -- <?php echo $value; ?> --</option>
                        <?php } ?>
                            <!--<option value="2" <?php if(isset($content_type) && $content_type==2){ echo "selected=selected";} ?>> -- Video --</option>
                            <option value="3" <?php if(isset($content_type) && $content_type==3){ echo "selected=selected";} ?>> -- Ảnh --</option>
                            <option value="4" <?php if(isset($content_type) && $content_type==4){ echo "selected=selected";} ?>> -- Nhạc chờ --</option>
                            <option value="5" <?php if(isset($content_type) && $content_type==5){ echo "selected=selected";} ?>> -- Sms kute --</option>-->
                        </select>
                    </div>
                </li>

                <li class="clearfix"><label>&nbsp;</label>
                    <div class="filltext">
                        <input type="submit" class="btn-bigblue" value=" Tìm kiếm"> 
                    </div>
                </li>
            </ul>
        </form>
    </div>          
    <div class="box">
        <div class="fillter clearfix">
            <div class="fl">Tìm thấy <strong class="clred"><?php echo $count; ?></strong> kết quả trong <strong class="clred"><?php echo $max_page; ?></strong> trang</div>
            <div class="fr">
                <a class="excel" href="#"><strong>Xuất ra file excel</strong></a>
                <ul class="paging">
                    <?php echo Paging::show_paging_cp($max_page,$page,$path_paging); ?>
                </ul>
            </div>
        </div>
        <div class="table clearfix">
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                <tbody>
                    <tr class="bg-grey">
                        <!--<td width="4%" ><strong>STT</strong></td>-->
                        <td width="8%"><strong>Tài khoản </strong></td>
                        <td width="5%"><strong>RefCode </strong></td>
                        <td width="10%" ><strong>Sản phẩm</strong></td>
                        <td width="8%" ><strong>Số gửi tin</strong></td>
                        <td width="5%" ><strong>Đầu số</strong></td>
                        <td width="13%" ><strong>Cú pháp</strong></td>
                        <td width="13%" ><strong>MT</strong></td>
                        <td width="5%" ><strong>Tỉ lệ/Doanh thu</strong></td>
                        <td width="8%" ><strong>Thời gian</strong></td>
                    </tr>

                    <?php foreach($data as $key=>$value){ ?>
                        <tr>
                            <td style="text-align: center; color: blue"><b><?php echo $username[$key]['username']; ?></b></td>
                            <td class="text-left">
                                <?php echo $username[$key]['refCode'];?>
                            </td>
                            <td class="text-left"> <b>
                                    <?php echo "<p style='color:blue'>".$partner[$key]['name']."</p></br>"; 
                                        if($value['type']==1){
                                            echo $game[$key]['title'];
                                        } else{
                                            echo $content[$value['type']];
                                        }
                                    ?>
                                </b>
                            </td>
                            <td class="text-right"><?php echo $value['mobile']; ?></td>
                            <td class="text-right"><?php echo $value['serviceNumber']; ?></td>
                            <td class="text-left"><?php echo $value['mo']; ?></td>
                            <td class="text-left"><?php echo $value['mt']; ?></td>
                            <td class="text-right"><?php echo "<p style='color:#FF9900'>".$rate_wap[$key]."%"."</p></br>".Common::format_price(round($money_wap[$key])); ?></td>
                            <td class="text-right"><?php echo date("H:i:s d-m-Y",$value['create_date']); ?></td>
                        </tr>
                        <?php }?>
                </tbody>
            </table>
        </div>
        <div class="fillter clearfix">
            <div class="fr">
                <ul class="paging">
                    <?php echo Paging::show_paging_cp($max_page,$page,$path_paging); ?>
                </ul>
            </div>
        </div>

    </div>
</div>

<script type="">
    function toggleApp(){
        var e = document.form1.search_type.value ;
        if(e==5){
            $("#content_type").show("slow");  
        }else{
            $("#content_type").hide("slow");   
        } 


    }
</script>                 